|
|
|
|
|
|
|
The UpDown control is another Common control used to accept input from users. However, the UpDown control is unique in that it is not designed to be a standalone control. Instead, it works with another ''buddy" control to allow users to modify its numeric values easily. In other words, if you have a text field that requires a numeric value, you can link an UpDown control to it so that users can run up and down through numbers without typing anything. |
|
|
|
|
|
|
|
|
The UpDown control, shown in Figure 12.19 with a text box, consists of a pair of arrow buttons. These buttons let users increment or decrement the value of a number. The UpDown control can be used with any other control that can handle numbers, including text boxes, labels, scrollbars, and sliders. |
|
|
|
|
|
|
|
|
Figure 12.19
The UpDown control allows users to adjust the value of a number. |
|
|
|
|
|
|
|
|
Setting Up the UpDown Control |
|
|
|
|
|
|
|
|
To set up the UpDown control, follow these steps: |
|
|
|
|
|
|
|
|
1. On your form, draw a control that can handle numbers, such as the TextBox control. |
|
|
|
|
|
|
|
|
2. Draw the UpDown control on your form. |
|
|
|
|
|
|
|
|
3. Set the BuddyControl property of the UpDown control to the name of the control that displays the numeric values. Note that you have to type the name of the control (such as Text1) or use the AutoBuddy property. |
|
|
|
|
|
|
|
|
4. Set the BuddyProperty of the UpDown control to Default. This action causes the UpDown control to update the default property of its Buddy control, such as the Text property of a text box. You can also set it to another property, as long as the property you select is numeric. |
|
|
|
|
|
|
|
|
After completing the basic setup of the UpDown control, you can set other properties to control its appearance and behavior. For controlling the appearance of the UpDown control, the two key properties are as follow: |
|
|
|
|
|
|
|
|
AlignmentControls whether the UpDown control appears to the left or the right of the Buddy control |
|
|
|
|
|
|
|
|
OrientationControls whether the UpDown control's buttons are oriented horizontally or vertically |
|
|
|
|
|
|
|
|
The effects of the Alignment and Orientation properties are shown in Figure 12.20. |
|
|
|
|
|